package tests;

import common.Utils;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;

public class LoginPage extends Utils {
    public static String url = "http://112.124.50.36:58080/sign-in.html";
    public LoginPage() {
        super(url);
    }

    //检查页面是否正常显示
    public void loginPageRight(){
        driver.findElement(By.cssSelector("body > div.page.page-center > div > div.row.align-items-center.g-4 > div > div.container-tight > div.card.card-md > div"));
        driver.findElement(By.cssSelector("#submit"));
    }

    //检查登录成功后页面是否正常
    public void logSuc() throws InterruptedException {
        driver.findElement(By.cssSelector("#username")).sendKeys("lll");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();
        //Thread.sleep(3000);
        driver.findElement(By.cssSelector("#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post"));
       // driver.quit();
        driver.navigate().back();

    }

    //测试登录失败
    public void logFail() throws InterruptedException {
        driver.navigate().refresh();
        driver.findElement(By.cssSelector("#username")).sendKeys("lll");
        driver.findElement(By.cssSelector("#password")).sendKeys("1234567");
        driver.findElement(By.cssSelector("#submit")).click();
        Alert alert = driver.switchTo().alert();

    }
}
